Imports System.Data
Partial Class Admin_frmModifyState
    Inherits System.Web.UI.Page
    Dim VarStateId As String
    Dim _StateVO As New StateVo
    Dim _BO As New Bo
    Dim _EmployeeId As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _EmployeeId = Session("EmpId")
        If _EmployeeId = "" Then
            Response.Redirect("../Client/frmLogin.aspx")
        End If
        VarStateId = Request.QueryString("StateId")
        If VarStateId = "" Then
            Response.Redirect("frmTabState.aspx")
        Else
            If Not IsPostBack Then
                GetStateData()
                CountryData()
            End If
        End If
    End Sub
    Sub GetStateData()
        _StateVO = _BO.getStateById(VarStateId)
        ddlCountry.SelectedValue = _StateVO.CountryId
        ddlCountry.Text = _StateVO.CountryId
        lblStateId.Text = _StateVO.StateId
        txtStateName.Text = _StateVO.StateName
    End Sub
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        SetData()
        Session("EmpId") = _EmployeeId
    End Sub
    Sub SetData()
        _StateVO.CountryId = ddlCountry.SelectedValue
        _StateVO.StateId = lblStateId.Text
        _StateVO.StateName = txtStateName.Text
        _BO.ModifyState(_StateVO)
        ClearAll()
    End Sub
    Public Sub ClearAll()
        txtStateName.Text = ""
        MsgBox("State Modified")
        Response.Redirect("frmTabState.aspx", False)
    End Sub
    Public Sub CountryData()
        Dim dtCountry As DataTable
        dtCountry = _BO.getcountry()
        ddlCountry.DataSource = dtCountry
        ddlCountry.DataValueField = dtCountry.Columns(0).ToString
        ddlCountry.DataTextField = dtCountry.Columns(1).ToString
        ddlCountry.DataBind()
    End Sub

    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtStateName.Text = ""
    End Sub
End Class
